1260B - Obtain Two Zeroes - CodeForces Solution


binary search math *1300

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(), (v).end()
#define all1(v) (v).begin() + 1, (v).end()
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 1e9 + 7, mod = 998244353;
const ll linf = 9e18 + 7;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int MAXINT = 2147483647;
const double PI = acos(-1);
#define i128 __int128
#define rep(i, n) for(int i = (0); i < (ll)(n); i++)
#define FL(i, l, r) for(int i = (ll)(l); i <= (ll)(r); i++)
#define FR(i, r, l) for(int i = (ll)(r); i <= (ll)(l); i--)
#define fix(x) cout << fixed << setprecision(x);
#define vc vector
// #define ll __int128
// inline void read(int &x)
// {
//     char c;int f=1;
//     while(!isdigit(c=getchar()))if(c=='-')f=-1;
//     x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
//     x*=f;
// }
// inline void read(ll &x)
// {
//     char c;int f=1;
//     while(!isdigit(c=getchar()))if(c=='-')f=-1;
//     x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
//     x*=f;
// }
// 输出__int128
// void print(ll x)
// {
//     if(x < 0) putchar('-'), x = -x;
//     if(x > 9) print(x / 10);
//     putchar(x % 10 + '0');
// }

template<typename T1>
void print(vector<T1> &v, bool OutSize = false, bool isendl = false)
{
    if(OutSize) cout << v.size() << '\n';
    for(auto &t : v) cout << t << (isendl ? '\n' : ' ');
    if(!isendl) cout << '\n';
}

template<typename T2>
void pr(T2 x)
{
    cout << x << endl;
}

int min(int a, int b)
{
    if(a <= b) return a;
    return b;
}

int max(int a, int b)
{
    if(a >= b) return a;
    return b;
}

bool is_prime(int x)
{
    if(x < 2) return false;
    for(int i = 2; i <= x / i; i++)
        if(x % i == 0) return false;
    return true;
}

int qmi(int a, int k, int p)
{
    a %= p;
    int res = 1;
    while(k)
    {
        if(k & 1) res = res * a % p;
        a = a * a % p;
        k >>= 1;
    }
    return res;
}

vector<int> gi(int n)
{
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    return v;
}

vector<int> gi1(int n)
{
    vector<int> v(n + 1);
    for(int i = 1; i <= n; i++) cin >> v[i];
    return v;
}

//--------------------------// A C //--------------------------------------

void solve()
{   
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b); 
    if((a + b) % 3 == 0 && a * 2 >= b) pr("YES");
    else pr("NO");
}    

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while(t--)
        solve();
}


Comments

Submit
0 Comments
More Questions

450A - Jzzhu and Children
546A - Soldier and Bananas
32B - Borze
1651B - Prove Him Wrong
381A - Sereja and Dima
41A - Translation
1559A - Mocha and Math
832A - Sasha and Sticks
292B - Network Topology
1339A - Filling Diamonds
910A - The Way to Home
617A - Elephant
48A - Rock-paper-scissors
294A - Shaass and Oskols
1213A - Chips Moving
490A - Team Olympiad
233A - Perfect Permutation
1360A - Minimal Square
467A - George and Accommodation
893C - Rumor
227B - Effective Approach
1534B - Histogram Ugliness
1611B - Team Composition Programmers and Mathematicians
110A - Nearly Lucky Number
1220B - Multiplication Table
1644A - Doors and Keys
1644B - Anti-Fibonacci Permutation
1610A - Anti Light's Cell Guessing
349B - Color the Fence
144A - Arrival of the General